import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEAction } from './ipsdeaction';
import { IPSDEActionLogic } from './ipsdeaction-logic';
import { IPSDEDataSync } from '../datasync/ipsdedata-sync';
import { IPSDEField } from '../defield/ipsdefield';
import { IPSDEFValueRule } from '../defield/valuerule/ipsdefvalue-rule';
import { IPSDERBase } from '../der/ipsderbase';
import { IPSDEDataSet } from '../ds/ipsdedata-set';
import { IPSDELogic } from '../logic/ipsdelogic';
import { IPSDEMainState } from '../mainstate/ipsdemain-state';
import { IPSDENotify } from '../notify/ipsdenotify';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysLogic } from '../../res/ipssys-logic';
import { IPSSysSFPlugin } from '../../res/ipssys-sfplugin';
import { IPSSysSequence } from '../../res/ipssys-sequence';
import { IPSSysTranslator } from '../../res/ipssys-translator';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEActionLogicImpl extends PSModelObjectImpl implements IPSDEActionLogic {
  get actionLogicType(): 1 | 0 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 50 | 51 | 52 | 53 | 54 | 55 | 56 {
    return this.M.actionLogicType;
  }

  get attachMode(): 'PREPARE' | 'CHECK' | 'BEFORE' | 'AFTER' {
    return this.M.attachMode;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dataSyncEvent(): 1 | 2 | 4 | 256 | 512 {
    return this.M.dataSyncEvent != null ? this.M.dataSyncEvent : 0;
  }

  protected dstpsde: IPSDataEntity | null = null;

  getDstPSDE(): IPSDataEntity | null {
    if (this.dstpsde != null) return this.dstpsde;
    const value = this.M.getDstPSDE;
    if (value == null) {
      return null;
    }
    this.dstpsde = this.getPSModel4('dataentity.IPSDataEntity', value, 'getDstPSDE') as IPSDataEntity;
    return this.dstpsde;
  }

  get dstPSDE(): IPSDataEntity | null {
    return this.getDstPSDE();
  }

  getDstPSDEMust(): IPSDataEntity {
    const value = this.getDstPSDE();
    if (value == null) {
      throw new Error('未指定目标实体');
    }
    return value;
  }

  protected dstpsdeaction: IPSDEAction | null = null;

  getDstPSDEAction(): IPSDEAction | null {
    if (this.dstpsdeaction != null) return this.dstpsdeaction;
    const value = this.M.getDstPSDEAction;
    if (value == null) {
      return null;
    }
    this.dstpsdeaction = this.getDstPSDEMust().findPSDEAction(value);
    return this.dstpsdeaction;
  }

  get dstPSDEAction(): IPSDEAction | null {
    return this.getDstPSDEAction();
  }

  getDstPSDEActionMust(): IPSDEAction {
    const value = this.getDstPSDEAction();
    if (value == null) {
      throw new Error('未指定目标实体行为');
    }
    return value;
  }

  protected dstpsdedataset: IPSDEDataSet | null = null;

  getDstPSDEDataSet(): IPSDEDataSet | null {
    if (this.dstpsdedataset != null) return this.dstpsdedataset;
    const value = this.M.getDstPSDEDataSet;
    if (value == null) {
      return null;
    }
    this.dstpsdedataset = this.getDstPSDEMust().findPSDEDataSet(value);
    return this.dstpsdedataset;
  }

  get dstPSDEDataSet(): IPSDEDataSet | null {
    return this.getDstPSDEDataSet();
  }

  getDstPSDEDataSetMust(): IPSDEDataSet {
    const value = this.getDstPSDEDataSet();
    if (value == null) {
      throw new Error('未指定目标实体数据集');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get errorCode(): number {
    return this.M.errorCode != null ? this.M.errorCode : 0;
  }

  get errorInfo(): string {
    return this.M.errorInfo;
  }

  protected errorinfopslanguageres: IPSLanguageRes | null = null;

  getErrorInfoPSLanguageRes(): IPSLanguageRes | null {
    if (this.errorinfopslanguageres != null) return this.errorinfopslanguageres;
    const value = this.M.getErrorInfoPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.errorinfopslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getErrorInfoPSLanguageRes') as IPSLanguageRes;
    return this.errorinfopslanguageres;
  }

  get errorInfoPSLanguageRes(): IPSLanguageRes | null {
    return this.getErrorInfoPSLanguageRes();
  }

  getErrorInfoPSLanguageResMust(): IPSLanguageRes {
    const value = this.getErrorInfoPSLanguageRes();
    if (value == null) {
      throw new Error('未指定错误信息语言资源对象');
    }
    return value;
  }

  get exceptionObj(): string {
    return this.M.exceptionObj;
  }

  get logicParams(): IModel {
    return this.M.logicParams;
  }

  protected majorpsder: IPSDERBase | null = null;

  getMajorPSDER(): IPSDERBase | null {
    if (this.majorpsder != null) return this.majorpsder;
    const value = this.M.getMajorPSDER;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.majorpsder = ipsdataentity.findMajorPSDERBase(value);
    }
    return this.majorpsder;
  }

  get majorPSDER(): IPSDERBase | null {
    return this.getMajorPSDER();
  }

  getMajorPSDERMust(): IPSDERBase {
    const value = this.getMajorPSDER();
    if (value == null) {
      throw new Error('未指定主控关系');
    }
    return value;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdedatasync: IPSDEDataSync | null = null;

  getPSDEDataSync(): IPSDEDataSync | null {
    if (this.psdedatasync != null) return this.psdedatasync;
    const value = this.M.getPSDEDataSync;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdedatasync = ipsdataentity.findPSDEDataSync(value);
    }
    return this.psdedatasync;
  }

  get psDEDataSync(): IPSDEDataSync | null {
    return this.getPSDEDataSync();
  }

  getPSDEDataSyncMust(): IPSDEDataSync {
    const value = this.getPSDEDataSync();
    if (value == null) {
      throw new Error('未指定实体数据同步');
    }
    return value;
  }

  protected psdefvaluerule: IPSDEFValueRule | null = null;

  getPSDEFValueRule(): IPSDEFValueRule | null {
    if (this.psdefvaluerule != null) return this.psdefvaluerule;
    const value = this.M.getPSDEFValueRule;
    if (value == null) {
      return null;
    }
    this.psdefvaluerule = this.getPSDEFieldMust().findPSDEFValueRule(value);
    return this.psdefvaluerule;
  }

  get psDEFValueRule(): IPSDEFValueRule | null {
    return this.getPSDEFValueRule();
  }

  getPSDEFValueRuleMust(): IPSDEFValueRule {
    const value = this.getPSDEFValueRule();
    if (value == null) {
      throw new Error('未指定属性值规则');
    }
    return value;
  }

  protected psdefield: IPSDEField | null = null;

  getPSDEField(): IPSDEField | null {
    if (this.psdefield != null) return this.psdefield;
    const value = this.M.getPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdefield = ipsdataentity.findPSDEField(value);
    }
    return this.psdefield;
  }

  get psDEField(): IPSDEField | null {
    return this.getPSDEField();
  }

  getPSDEFieldMust(): IPSDEField {
    const value = this.getPSDEField();
    if (value == null) {
      throw new Error('未指定属性对象');
    }
    return value;
  }

  protected psdelogic: IPSDELogic | null = null;

  getPSDELogic(): IPSDELogic | null {
    if (this.psdelogic != null) return this.psdelogic;
    const value = this.M.getPSDELogic;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdelogic = ipsdataentity.findPSDELogic(value);
    }
    return this.psdelogic;
  }

  get psDELogic(): IPSDELogic | null {
    return this.getPSDELogic();
  }

  getPSDELogicMust(): IPSDELogic {
    const value = this.getPSDELogic();
    if (value == null) {
      throw new Error('未指定实体逻辑');
    }
    return value;
  }

  protected psdemainstate: IPSDEMainState | null = null;

  getPSDEMainState(): IPSDEMainState | null {
    if (this.psdemainstate != null) return this.psdemainstate;
    const value = this.M.getPSDEMainState;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdemainstate = ipsdataentity.findPSDEMainState(value);
    }
    return this.psdemainstate;
  }

  get psDEMainState(): IPSDEMainState | null {
    return this.getPSDEMainState();
  }

  getPSDEMainStateMust(): IPSDEMainState {
    const value = this.getPSDEMainState();
    if (value == null) {
      throw new Error('未指定实体主状态');
    }
    return value;
  }

  protected psdenotify: IPSDENotify | null = null;

  getPSDENotify(): IPSDENotify | null {
    if (this.psdenotify != null) return this.psdenotify;
    const value = this.M.getPSDENotify;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdenotify = ipsdataentity.findPSDENotify(value);
    }
    return this.psdenotify;
  }

  get psDENotify(): IPSDENotify | null {
    return this.getPSDENotify();
  }

  getPSDENotifyMust(): IPSDENotify {
    const value = this.getPSDENotify();
    if (value == null) {
      throw new Error('未指定实体通知');
    }
    return value;
  }

  protected pssyslogic: IPSSysLogic | null = null;

  getPSSysLogic(): IPSSysLogic | null {
    if (this.pssyslogic != null) return this.pssyslogic;
    const value = this.M.getPSSysLogic;
    if (value == null) {
      return null;
    }
    this.pssyslogic = this.getPSModel4('res.IPSSysLogic', value, 'getPSSysLogic') as IPSSysLogic;
    return this.pssyslogic;
  }

  get psSysLogic(): IPSSysLogic | null {
    return this.getPSSysLogic();
  }

  getPSSysLogicMust(): IPSSysLogic {
    const value = this.getPSSysLogic();
    if (value == null) {
      throw new Error('未指定系统预置逻辑');
    }
    return value;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后台扩展插件');
    }
    return value;
  }

  protected pssyssequence: IPSSysSequence | null = null;

  getPSSysSequence(): IPSSysSequence | null {
    if (this.pssyssequence != null) return this.pssyssequence;
    const value = this.M.getPSSysSequence;
    if (value == null) {
      return null;
    }
    this.pssyssequence = this.getPSModel4('res.IPSSysSequence', value, 'getPSSysSequence') as IPSSysSequence;
    return this.pssyssequence;
  }

  get psSysSequence(): IPSSysSequence | null {
    return this.getPSSysSequence();
  }

  getPSSysSequenceMust(): IPSSysSequence {
    const value = this.getPSSysSequence();
    if (value == null) {
      throw new Error('未指定系统值序列');
    }
    return value;
  }

  protected pssystranslator: IPSSysTranslator | null = null;

  getPSSysTranslator(): IPSSysTranslator | null {
    if (this.pssystranslator != null) return this.pssystranslator;
    const value = this.M.getPSSysTranslator;
    if (value == null) {
      return null;
    }
    this.pssystranslator = this.getPSModel4('res.IPSSysTranslator', value, 'getPSSysTranslator') as IPSSysTranslator;
    return this.pssystranslator;
  }

  get psSysTranslator(): IPSSysTranslator | null {
    return this.getPSSysTranslator();
  }

  getPSSysTranslatorMust(): IPSSysTranslator {
    const value = this.getPSSysTranslator();
    if (value == null) {
      throw new Error('未指定系统值转换器');
    }
    return value;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cloneParam(): boolean {
    return this.M.cloneParam != null ? this.M.cloneParam : false;
  }

  get enableBackend(): boolean {
    return this.M.enableBackend != null ? this.M.enableBackend : true;
  }

  get ignoreException(): boolean {
    return this.M.ignoreException != null ? this.M.ignoreException : false;
  }

  get internalLogic(): boolean {
    return this.M.internalLogic;
  }

  get prepareLast(): boolean {
    return this.M.prepareLast != null ? this.M.prepareLast : false;
  }

  get valid(): boolean {
    return this.M.valid != null ? this.M.valid : true;
  }

  get cls(): string {
    return 'PSDEActionLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.action.IPSDEActionLogic') return true;
    return super.instanceof(cls);
  }
}
